/*
 *  Vector4.h
 *  softwarerenderer
 *
 *  Created by Johannes Loepelmann on 22.02.09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */
class Vector4 {
	public:
	float x,y,z,w;
	
	Vector4();
	
	Vector4(float x, float y, float z, float w);
	
	void set(float x, float y, float z, float w);
	
	float lengthSquared();
	float length();
	
	float dot(Vector4* vec);
	
	Vector4* cross(Vector4* other);
	
	void normalize();
	
	Vector4 & operator+=(const Vector4 & other);
	Vector4 & operator-=(const Vector4 & other);
	
	Vector4 & operator*=(const float s);
	Vector4 & operator/=(const float s);
};

inline Vector4::Vector4 operator + (const Vector4::Vector4 &v1,
									 const Vector4::Vector4 &v2)
{
	return Vector4::Vector4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w);
}

inline Vector4::Vector4 operator - (Vector4::Vector4 &v1,
									 const Vector4::Vector4 &v2)
{
	return Vector4::Vector4(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w);
}

inline Vector4::Vector4 operator - (const Vector4::Vector4 &v1)
{
	return Vector4::Vector4(-v1.x, -v1.y, -v1.z, -v1.w);
}

inline Vector4::Vector4 operator * (const Vector4::Vector4 &v,
									 const float &s)
{
	return Vector4::Vector4(v.x * s, v.y * s, v.z * s, v.w * s);
}

inline Vector4::Vector4 operator * (const float & s,
									 const Vector4::Vector4 &v)
{
	return Vector4::Vector4(v.x * s, v.y * s, v.z * s, v.w * s);
}

inline Vector4::Vector4 operator / (const Vector4::Vector4 &v,
									 const float & s)
{
	return Vector4::Vector4(v.x / s, v.y / s, v.z / s, v.w / s);
}
